<template>
  <div class="goods_desc">
    <div class="head">
      <div class="head_left" @click="hideDesc">
        <i class="iconfont iconfanhui"></i>
      </div>

      <div class="head_center">商品详情</div>
      <div class="head_right" @click="saveDesc">保存</div>
    </div>
    <div class="container con">
      <vue-html5-editor :content="goods_desc" @change="updateData"></vue-html5-editor>
    </div>
  </div>
</template>

<script>
export default {
  props: ["goods_desc", "goods_id"],
  data() {
    return {
      desc: ""
    };
  },
  mounted() {
    this.desc = this.goods_desc;
  },
  methods: {
    updateData(data) {
      this.desc = data;
    },
    hideDesc() {
      this.$emit("hideDesc");
    },
    saveDesc() {
      this.appJS.ajax(
        "user.goods_desc_edit_post",
        "post",
        {
          goods_id: this.goods_id,
          goods_desc: this.desc
        },
        res => {
          if (res.recode == 1) {
            this.$toast("编辑成功");
            setTimeout(() => {
              this.$emit("hideDesc", this.desc);
            }, 1000);
          }
        }
      );
    }
  },
  components: {}
};
</script>

<style lang='less'>
.goods_desc {
  min-height: 100vh;
  widows: 100%;
  background: #fff;
  .vue-html5-editor {
    min-height: calc(100vh - 200px);
    border: 0;
  }
  .con {
    height: 100vh;
    overflow: auto;
  }
  .head {
    height: 60px;
    background: @color;
    padding: 0 0.5rem;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1999;
    width: 100%;
    max-width: @maxWidth;
    margin: 0 auto;
    .head_left {
      height: 100%;
      width: 1.5rem;
      position: absolute;
      display: flex;
      justify-content: flex-start;
      align-items: flex-end;
      padding-bottom: 0.5rem;
      .iconfanhui {
        font-size: 1.1rem !important;
      }
    }
    .head_close {
      height: 100%;
      width: 1.5rem;
      position: absolute;
      display: flex;
      justify-content: flex-start;
      align-items: flex-end;
      left: 2.5rem;
      padding-bottom: 0.5rem;
    }
    .head_center {
      height: 100%;
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: flex-end;
      font-size: 0.8rem;
      padding-bottom: 0.5rem;
    }
    .head_right {
      height: 100%;
      width: 4rem;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      position: absolute;
      right: 0;
      top: 0;
      box-sizing: border-box;
      padding-right: 0.5rem;
      align-items: flex-end;
      padding-bottom: 0.5rem;
      .iconfont {
        font-size: 1.1rem;
      }
      font-size: 0.7rem;
    }
  }
}
</style>
